package sgg_hsp_data_structures._06_sort;

public class BubbleSort {


    public static void main(String[] args) {
        int[] arr = ArrUtils.getArr();
        ArrUtils.printCurTime();
        bubbleSort(arr);
        ArrUtils.printCurTime();
    }


    public static void bubbleSort(int[] arr) {

        int temp = 0;
        boolean isExchangeed = false;
        for (int i = 0; i < arr.length; i++) {

            for (int j = 0; j < arr.length - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    isExchangeed = true;
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
            if (!isExchangeed) {
                break;
            } else {
                isExchangeed = false;
            }
        }
    }

}
